/*
 * Class ItemSelect
 *
 * Version 1.0
 *
 * Friday, August 22, 2008
 *
 * Created by Palidino76
 */

package palidino76.rs2.io.packets;

import palidino76.rs2.*;
import palidino76.rs2.player.Player;
import palidino76.rs2.player.items.PlayerItems;
import palidino76.rs2.util.Misc;

public class ItemSelect implements Packet {
    /**
     * Handles certain item selecting such as eating and drinking.
     * @param p The Player which the frame should be handled for.
     * @param packetId The packet id this belongs to.
     * @param packetSize The amount of bytes being recieved for this packet.
     */
    public void handlePacket(Player p, int packetId, int packetSize) {
        if (p == null || p.stream == null) {
            return;
        }
        int junk = p.stream.readUnsignedByte();
        int interfaceId = p.stream.readUnsignedWord();
        junk = p.stream.readUnsignedByte();
        int itemId = p.stream.readUnsignedWordBigEndian();
        int itemSlot = p.stream.readUnsignedWordA();
		PlayerItems pi = new PlayerItems();
        p.attackingPlayer = false;
	p.usingAutoCast = false;

	if (p.eatDelay > 0) {
	    return;
	}
        if (itemSlot < 0 || itemSlot > p.items.length || p.items[itemSlot] != itemId) {
            return;
        }
        if (p.isDead || p.skillLvl[3] < 1) {
            return;
        }
	int lastHP = 0;
        if (interfaceId == 149) {
            switch (itemId) {
						case 8008: //Lumby teleport
            p.teleportTo(3222, 3218, 0, 4, 4, 75133, 75134, 678, 0, -1, 0);
            pi.deleteItem(p, itemId, itemSlot, 1);
            p.addSkillXP(100,6);
            break;
	case 8010://Camelot teleport
            p.teleportTo(2757, 3477, 0, 4, 4, 75133, 75134, 678, 0, -1, 0);
            pi.deleteItem(p, itemId, itemSlot, 1);
            p.addSkillXP(100,6);
            break;
	case 8009://Falador teleport
            p.teleportTo(2964, 3378, 0, 4, 4, 75133, 75134, 678, 0, -1, 0);
            pi.deleteItem(p, itemId, itemSlot, 1);
            p.addSkillXP(100,6);
            break;
	case 8007://Varrock teleport
            p.teleportTo(3210, 3424, 0, 4, 4, 75133, 75134, 678, 0, -1, 0);
            pi.deleteItem(p, itemId, itemSlot, 1);
            p.addSkillXP(100,6);
            break;
	case 8011://Ardougne teleport
            p.teleportTo(2661, 3305, 0, 4, 4, 75133, 75134, 678, 0, -1, 0);
            pi.deleteItem(p, itemId, itemSlot, 1);
            p.addSkillXP(100,6);
            break;
	case 8012://Watchtower teleport
            p.teleportTo(2548, 3114, 0, 4, 4, 75133, 75134, 678, 0, -1, 0);
            pi.deleteItem(p, itemId, itemSlot, 1);
            p.addSkillXP(100,6);
            break;

		case 3024:
		case 3026:
		case 3028:
		case 3030:
			p.requestAnim(829, 0);
			Engine.playerItems.deleteItem(p, itemId, itemSlot, 1);
			if (itemId != 3030)
				Engine.playerItems.addItem(p, itemId+2, 1);
			else
				Engine.playerItems.addItem(p, 229, 1);
			p.skillLvl[0] = p.getLevelForXP(0);
			p.skillLvl[1] = p.getLevelForXP(1);
			p.skillLvl[2] = p.getLevelForXP(2);
			p.skillLvl[4] = p.getLevelForXP(4);
			p.skillLvl[5] = p.getLevelForXP(5);
			p.skillLvl[6] = p.getLevelForXP(6);
			p.skillLvl[7] = p.getLevelForXP(7);
			p.skillLvl[8] = p.getLevelForXP(8);
			p.skillLvl[9] = p.getLevelForXP(9);
			p.skillLvl[10] = p.getLevelForXP(10);
			p.skillLvl[11] = p.getLevelForXP(11);
			p.skillLvl[12] = p.getLevelForXP(12);
			p.skillLvl[13] = p.getLevelForXP(13);
			p.skillLvl[14] = p.getLevelForXP(14);
			p.skillLvl[15] = p.getLevelForXP(15);
 			p.skillLvl[16] = p.getLevelForXP(16);
			p.skillLvl[17] = p.getLevelForXP(17);
			p.skillLvl[18] = p.getLevelForXP(18);
			p.skillLvl[19] = p.getLevelForXP(19);
			p.skillLvl[20] = p.getLevelForXP(20);
			p.skillLvl[21] = p.getLevelForXP(21);
			p.skillLvl[22] = p.getLevelForXP(22);
			p.skillLvl[23] = p.getLevelForXP(23);
			p.frames.playSound(p, 2401, 1, 0);
			for (int i = 0; i < p.skillLvl.length; i++)
				p.frames.setSkillLvl(p, i);
		break;

		case 6685:
			p.requestAnim(829, 0);
			Engine.playerItems.deleteItem(p, itemId, itemSlot, 1);
			Engine.playerItems.addItem(p, 6687, 1);
			p.skillLvl[1] += 18;
			p.skillLvl[2] -= p.getLevelForXP(2) / 10 + 10;
			p.updateHP(p.getLevelForXP(3) / 10 * 2, true);
			for (int i = 0; i < 23; i++)
				p.frames.setSkillLvl(p, i);
			p.eatDelay = 1;
			p.potionType = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 6687:
			p.requestAnim(829, 0);
			Engine.playerItems.deleteItem(p, itemId, itemSlot, 1);
			Engine.playerItems.addItem(p, 6689, 1);
			p.skillLvl[1] += 18;
			p.skillLvl[2] -= p.getLevelForXP(2) / 10 + 10;
			p.updateHP(p.getLevelForXP(3) / 10 * 2, true);
			for (int i = 0; i < 23; i++)
				p.frames.setSkillLvl(p, i);
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 6689:
			p.requestAnim(829, 0);
			Engine.playerItems.deleteItem(p, itemId, itemSlot, 1);
			Engine.playerItems.addItem(p, 6691, 1);
			p.skillLvl[1] += 18;
			p.skillLvl[2] -= p.getLevelForXP(2) / 10 + 10;
			p.updateHP(p.getLevelForXP(3) / 10 * 2, true);
			for (int i = 0; i < 23; i++)
				p.frames.setSkillLvl(p, i);
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 6691:
			p.requestAnim(829, 0);
			Engine.playerItems.deleteItem(p, itemId, itemSlot, 1);
			Engine.playerItems.addItem(p, 229, 1);
			p.skillLvl[1] += 18;
			p.skillLvl[2] -= p.getLevelForXP(2) / 10 + 10;
			p.updateHP(p.getLevelForXP(3) / 10 * 2, true);
			for (int i = 0; i < 23; i++)
				p.frames.setSkillLvl(p, i);
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 4049:
			p.requestAnim(829, 0);
			Engine.playerItems.deleteItem(p, itemId, itemSlot, 1);
			p.updateHP(12, true);
			p.eatDelay = 3;
		break;

		/**
		 * Slayer items.
		 */
		case 4155:
			if (p.slayerTask) {
				p.frames.sendMessage(p, "Slayer task: "+p.slayerAmount1+" "+Server.engine.getNPCName(p.slayerType1)+".");
			} else {
				p.frames.sendMessage(p, "You currently have no slayer task. please return to your slayer master for a task.");
			}
		break;

		/**
		 * Bones
		 */
		        case 526://Bones.
                case 528://Burnt Bones.
                case 2530://Bones 2.
                case 2859://Wolf Bones.
                case 3187://Bones 3.
                    if (p.buryingBonesDelay <= 0) {
                        p.buryingBonesDelay = 3;
                        p.addSkillXP(4.5, 5);
                        p.requestAnim(8908, 0);
                        p.frames.sendMessage(p, "You dig a hole in the ground...");
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.frames.sendMessage(p, "You bury the bones.");
                    }
                break;

                case 530://Bat Bones.
                    if (p.buryingBonesDelay <= 0) {
                        p.buryingBonesDelay = 3;
                        p.addSkillXP(5.3, 5);
                        p.requestAnim(8908, 0);
                        p.frames.sendMessage(p, "You dig a hole in the ground...");
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.frames.sendMessage(p, "You bury the bones.");
                    }
                break;

                case 532://Big Bones.
                case 3125://Jogre Bones.
                    if (p.buryingBonesDelay <= 0) {
                        p.buryingBonesDelay = 3;
                        p.addSkillXP(15, 5);
                        p.requestAnim(8908, 0);
                        p.frames.sendMessage(p, "You dig a hole in the ground...");
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.frames.sendMessage(p, "You bury the bones.");
                    }
                break;

                case 534://Babydragon Bones.
                    if (p.buryingBonesDelay <= 0) {
                        p.buryingBonesDelay = 3;
                        p.addSkillXP(30, 5);
                        p.requestAnim(8908, 0);
                        p.frames.sendMessage(p, "You dig a hole in the ground...");
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.frames.sendMessage(p, "You bury the bones.");
                    }
                break;

                case 536://Dragon Bones.
                    if (p.buryingBonesDelay <= 0) {
                        p.buryingBonesDelay = 3;
                        p.addSkillXP(72, 5);
                        p.requestAnim(8908, 0);
                        p.frames.sendMessage(p, "You dig a hole in the ground...");
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.frames.sendMessage(p, "You bury the bones.");
                    }
                break;

                case 3123://Shaikahan Bones.
                    if (p.buryingBonesDelay <= 0) {
                        p.buryingBonesDelay = 3;
                        p.addSkillXP(25, 5);
                        p.requestAnim(8908, 0);
                        p.frames.sendMessage(p, "You dig a hole in the ground...");
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.frames.sendMessage(p, "You bury the bones.");
                    }
                break;

                case 3127://Burnt Jogre Bones.
                    if (p.buryingBonesDelay <= 0) {
                        p.buryingBonesDelay = 3;
                        p.addSkillXP(16, 5);
                        p.requestAnim(8908, 0);
                        p.frames.sendMessage(p, "You dig a hole in the ground...");
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.frames.sendMessage(p, "You bury the bones.");
                    }
                break;

                case 3128://Pasty Jogre Bones 1.
                case 3129://Pasty Jogre Bones 2.
                case 3131://Pasty Jogre Bones 3.
                case 3132://Pasty Jogre Bones 4.
                    if (p.buryingBonesDelay <= 0) {
                        p.buryingBonesDelay = 3;
                        p.addSkillXP(17, 5);
                        p.requestAnim(8908, 0);
                        p.frames.sendMessage(p, "You dig a hole in the ground...");
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.frames.sendMessage(p, "You bury the bones.");
                    }
                break;

                case 3130://Marinated Jogre Bones 1.
                case 3133://Marinated Jogre Bones 2.
                    if (p.buryingBonesDelay <= 0) {
                        p.buryingBonesDelay = 3;
                        p.addSkillXP(18, 5);
                        p.requestAnim(8908, 0);
                        p.frames.sendMessage(p, "You dig a hole in the ground...");
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.frames.sendMessage(p, "You bury the bones.");
                    }
                break;

                case 3179://Monkey Bones 1.
                case 3180://Monkey Bones 2.
                case 3181://Monkey Bones 3.
                case 3182://Monkey Bones 4.
                case 3183://Monkey Bones 5.
                case 3184://Monkey Bones 6.
                case 3185://Monkey Bones 7.
                case 3186://Monkey Bones 8.
                    if (p.buryingBonesDelay <= 0) {
                        p.buryingBonesDelay = 3;
                        p.addSkillXP(5, 5);
                        p.requestAnim(8908, 0);
                        p.frames.sendMessage(p, "You dig a hole in the ground...");
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.frames.sendMessage(p, "You bury the bones.");
                    }
                break;

                case 4812://Zogre Bones.
                    if (p.buryingBonesDelay <= 0) {
                        p.buryingBonesDelay = 3;
                        p.addSkillXP(22.5, 5);
                        p.requestAnim(8908, 0);
                        p.frames.sendMessage(p, "You dig a hole in the ground...");
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.frames.sendMessage(p, "You bury the bones.");
                    }
                break;

                case 4830://Fayrg Bones.
                    if (p.buryingBonesDelay <= 0) {
                        p.buryingBonesDelay = 3;
                        p.addSkillXP(84, 5);
                        p.requestAnim(8908, 0);
                        p.frames.sendMessage(p, "You dig a hole in the ground...");
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.frames.sendMessage(p, "You bury the bones.");
                    }
                break;

                case 4832://Raurg Bones.
                    if (p.buryingBonesDelay <= 0) {
                        p.buryingBonesDelay = 3;
                        p.addSkillXP(96, 5);
                        p.requestAnim(8908, 0);
                        p.frames.sendMessage(p, "You dig a hole in the ground...");
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.frames.sendMessage(p, "You bury the bones.");
                    }
                break;

                case 4834://Ourg Bones.
                    if (p.buryingBonesDelay <= 0) {
                        p.buryingBonesDelay = 3;
                        p.addSkillXP(140, 5);
                        p.requestAnim(8908, 0);
                        p.frames.sendMessage(p, "You dig a hole in the ground...");
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.frames.sendMessage(p, "You bury the bones.");
                    }
                break;

                case 6729://Dagannoth Bones.
                    if (p.buryingBonesDelay <= 0) {
                        p.buryingBonesDelay = 3;
                        p.addSkillXP(125, 5);
                        p.requestAnim(8908, 0);
                        p.frames.sendMessage(p, "You dig a hole in the ground...");
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.frames.sendMessage(p, "You bury the bones.");
                    }
                break;

                case 6812://Wyvern Bones.
                    if (p.buryingBonesDelay <= 0) {
                        p.buryingBonesDelay = 3;
                        p.addSkillXP(125, 5);
                        p.requestAnim(8908, 0);
                        p.frames.sendMessage(p, "You dig a hole in the ground...");
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.frames.sendMessage(p, "You bury the bones.");
                    }
                break;

		/**
		 * Drinks
		 */

		case 2434:
			Engine.playerItems.deleteItem(p, 2434, itemSlot, 1);
			Engine.playerItems.addItem(p, 139, 1);
			p.requestAnim(829, 0);
			p.skillLvl[5] += 18;
			if (p.skillLvl[5] > p.getLevelForXP(5)) {
				p.skillLvl[5] = p.getLevelForXP(5);
			}
			p.frames.setSkillLvl(p, 5);
			p.appearanceUpdateReq = true;
			p.updateReq = true;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 139:
			Engine.playerItems.deleteItem(p, 139, itemSlot, 1);
			Engine.playerItems.addItem(p, 141, 1);
			p.requestAnim(829, 0);
			p.skillLvl[5] += 18;
			if (p.skillLvl[5] > p.getLevelForXP(5)) {
				p.skillLvl[5] = p.getLevelForXP(5);
			}
			p.frames.setSkillLvl(p, 5);
			p.appearanceUpdateReq = true;
			p.updateReq = true;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 141:
			Engine.playerItems.deleteItem(p, 141, itemSlot, 1);
			Engine.playerItems.addItem(p, 143, 1);
			p.requestAnim(829, 0);
			p.skillLvl[5] += 18;
			if (p.skillLvl[5] > p.getLevelForXP(5)) {
				p.skillLvl[5] = p.getLevelForXP(5);
			}
			p.frames.setSkillLvl(p, 5);
			p.appearanceUpdateReq = true;
			p.updateReq = true;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 143:
			Engine.playerItems.deleteItem(p, 143, itemSlot, 1);
			Engine.playerItems.addItem(p, 229, 1);
			p.requestAnim(829, 0);
			p.skillLvl[5] += 18;
			if (p.skillLvl[5] > p.getLevelForXP(5)) {
				p.skillLvl[5] = p.getLevelForXP(5);
			}
			p.frames.setSkillLvl(p, 5);
			p.appearanceUpdateReq = true;
			p.updateReq = true;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 175:
			Engine.playerItems.deleteItem(p, 175, itemSlot, 1);
			Engine.playerItems.addItem(p, 177, 1);
			p.isPoisoned = false;
			p.poisonDelay = 0;
			p.poisonHitCount = 0;
			p.requestAnim(829, 0);
			p.frames.sendMessage(p, "You drink 1/3 of the potion. There is 2/3 of the potion left.");
			p.frames.sendMessage(p, "Your poison status has been restored.");
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 177:
			Engine.playerItems.deleteItem(p, 177, itemSlot, 1);
			Engine.playerItems.addItem(p, 179, 1);
			p.isPoisoned = false;
			p.poisonDelay = 0;
			p.poisonHitCount = 0;
			p.requestAnim(829, 0);
			p.frames.sendMessage(p, "You drink 1/3 of the potion. There is 1/3 of the potion left.");
			p.frames.sendMessage(p, "Your poison status has been restored.");
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 179:
			Engine.playerItems.deleteItem(p, 179, itemSlot, 1);
			Engine.playerItems.addItem(p, 229, 1);
			p.isPoisoned = false;
			p.poisonDelay = 0;
			p.poisonHitCount = 0;
			p.requestAnim(829, 0);
			p.frames.sendMessage(p, "You drink 1/3 of the potion. Your anti poison potion is empty");
			p.frames.sendMessage(p, "Your poison status has been restored.");
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 2442:
			Engine.playerItems.deleteItem(p, 2442, itemSlot, 1);
			Engine.playerItems.addItem(p, 163, 1);
			int abc2 = 0;
			int abc = p.getLevelForXP(1);
			int abc1 = abc / 10;
			abc2 = abc1 * 2;
			if (abc2 <= 1) {
				abc2 = 2;
			}
			p.skillLvl[1] = p.getLevelForXP(1);
			p.skillLvl[1] += abc2;
			p.frames.setSkillLvl(p, 1);
			p.requestAnim(829, 0);
			p.usingPotion = true;
			p.potionType = 1;
			p.defPot = true;
			p.statDelay = 45;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 163:
			Engine.playerItems.deleteItem(p, 163, itemSlot, 1);
			Engine.playerItems.addItem(p, 165, 1);
			abc2 = 0;
			abc = p.getLevelForXP(1);
			abc1 = abc / 10;
			abc2 = abc1 * 2;
			if (abc2 <= 1) {
				abc2 = 2;
			}
			p.skillLvl[1] = p.getLevelForXP(1);
			p.skillLvl[1] += abc2;
			p.frames.setSkillLvl(p, 1);
			p.requestAnim(829, 0);
			p.usingPotion = true;
			p.potionType = 1;
			p.defPot = true;
			p.statDelay = 45;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 165:
			Engine.playerItems.deleteItem(p, 165, itemSlot, 1);
			Engine.playerItems.addItem(p, 167, 1);
			abc2 = 0;
			abc = p.getLevelForXP(1);
			abc1 = abc / 10;
			abc2 = abc1 * 2;
			if (abc2 <= 1) {
				abc2 = 2;
			}
			p.skillLvl[1] = p.getLevelForXP(1);
			p.skillLvl[1] += abc2;
			p.frames.setSkillLvl(p, 1);
			p.requestAnim(829, 0);
			p.usingPotion = true;
			p.potionType = 1;
			p.defPot = true;
			p.statDelay = 45;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 167:
			Engine.playerItems.deleteItem(p, 167, itemSlot, 1);
			Engine.playerItems.addItem(p, 229, 1);
			abc2 = 0;
			abc = p.getLevelForXP(1);
			abc1 = abc / 10;
			abc2 = abc1 * 2;
			if (abc2 <= 1) {
				abc2 = 2;
			}
			p.skillLvl[1] = p.getLevelForXP(1);
			p.skillLvl[1] += abc2;
			p.frames.setSkillLvl(p, 1);
			p.requestAnim(829, 0);
			p.usingPotion = true;
			p.potionType = 1;
			p.defPot = true;
			p.statDelay = 45;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 2436:
			Engine.playerItems.deleteItem(p, 2436, itemSlot, 1);
			Engine.playerItems.addItem(p, 145, 1);
			abc2 = 0;
			abc = p.getLevelForXP(0);
			abc1 = abc / 10;
			abc2 = abc1 * 2;
			if (abc2 <= 1) {
				abc2 = 2;
			}
			p.skillLvl[0] = p.getLevelForXP(0);
			p.skillLvl[0] += abc2;
			p.frames.setSkillLvl(p, 0);
			p.requestAnim(829, 0);
			p.usingPotion = true;
			p.potionType = 0;
			p.atkPot = true;
			p.statDelay = 45;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 145:
			Engine.playerItems.deleteItem(p, 145, itemSlot, 1);
			Engine.playerItems.addItem(p, 147, 1);
			abc2 = 0;
			abc = p.getLevelForXP(0);
			abc1 = abc / 10;
			abc2 = abc1 * 2;
			if (abc2 <= 1) {
				abc2 = 2;
			}
			p.skillLvl[0] = p.getLevelForXP(0);
			p.skillLvl[0] += abc2;
			p.frames.setSkillLvl(p, 0);
			p.requestAnim(829, 0);
			p.usingPotion = true;
			p.potionType = 0;
			p.atkPot = true;
			p.statDelay = 45;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 147:
			Engine.playerItems.deleteItem(p, 147, itemSlot, 1);
			Engine.playerItems.addItem(p, 149, 1);
			abc2 = 0;
			abc = p.getLevelForXP(0);
			abc1 = abc / 10;
			abc2 = abc1 * 2;
			if (abc2 <= 1) {
				abc2 = 2;
			}
			p.skillLvl[0] = p.getLevelForXP(0);
			p.skillLvl[0] += abc2;
			p.frames.setSkillLvl(p, 0);
			p.requestAnim(829, 0);
			p.usingPotion = true;
			p.potionType = 0;
			p.atkPot = true;
			p.statDelay = 45;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 149:
			Engine.playerItems.deleteItem(p, 149, itemSlot, 1);
			Engine.playerItems.addItem(p, 229, 1);
			abc2 = 0;
			abc = p.getLevelForXP(0);
			abc1 = abc / 10;
			abc2 = abc1 * 2;
			if (abc2 <= 1) {
				abc2 = 2;
			}
			p.skillLvl[0] = p.getLevelForXP(0);
			p.skillLvl[0] += abc2;
			p.frames.setSkillLvl(p, 0);
			p.requestAnim(829, 0);
			p.usingPotion = true;
			p.potionType = 0;
			p.atkPot = true;
			p.statDelay = 45;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 2440:
			Engine.playerItems.deleteItem(p, 2440, itemSlot, 1);
			Engine.playerItems.addItem(p, 157, 1);
			abc2 = 0;
			abc = p.getLevelForXP(2);
			abc1 = abc / 10;
			abc2 = abc1 * 2;
			if (abc2 <= 1) {
				abc2 = 2;
			}
			p.skillLvl[2] = p.getLevelForXP(2);
			p.skillLvl[2] += abc2;
			p.frames.setSkillLvl(p, 2);
			p.requestAnim(829, 0);
			p.usingPotion = true;
			p.potionType = 2;
			p.strPot = true;
			p.statDelay = 45;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;


		case 157:
			Engine.playerItems.deleteItem(p, 157, itemSlot, 1);
			Engine.playerItems.addItem(p, 159, 1);
			abc2 = 0;
			abc = p.getLevelForXP(2);
			abc1 = abc / 10;
			abc2 = abc1 * 2;
			if (abc2 <= 1) {
				abc2 = 2;
			}
			p.skillLvl[2] = p.getLevelForXP(2);
			p.skillLvl[2] += abc2;
			p.frames.setSkillLvl(p, 2);
			p.requestAnim(829, 0);
			p.usingPotion = true;
			p.potionType = 2;
			p.strPot = true;
			p.statDelay = 45;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;


		case 159:
			Engine.playerItems.deleteItem(p, 159, itemSlot, 1);
			Engine.playerItems.addItem(p, 161, 1);
			abc2 = 0;
			abc = p.getLevelForXP(2);
			abc1 = abc / 10;
			abc2 = abc1 * 2;
			if (abc2 <= 1) {
				abc2 = 2;
			}
			p.skillLvl[2] = p.getLevelForXP(2);
			p.skillLvl[2] += abc2;
			p.frames.setSkillLvl(p, 2);
			p.requestAnim(829, 0);
			p.usingPotion = true;
			p.potionType = 2;
			p.strPot = true;
			p.statDelay = 45;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;


		case 161:
			Engine.playerItems.deleteItem(p, 161, itemSlot, 1);
			Engine.playerItems.addItem(p, 229, 1);
			abc2 = 0;
			abc = p.getLevelForXP(2);
			abc1 = abc / 10;
			abc2 = abc1 * 2;
			if (abc2 <= 1) {
				abc2 = 2;
			}
			p.skillLvl[2] = p.getLevelForXP(2);
			p.skillLvl[2] += abc2;
			p.frames.setSkillLvl(p, 2);
			p.requestAnim(829, 0);
			p.potionType = 2;
			p.strPot = true;
			p.usingPotion = true;
			p.statDelay = 45;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;

		case 121:
		case 123:
		case 125:
			Engine.playerItems.deleteItem(p, itemId, itemSlot, 1);
			if (itemId != 125) {
				Engine.playerItems.addItem(p, itemId+2, 1);
			} else {
				Engine.playerItems.addItem(p, 229, 1);
			}
 			int attVariable = 0;
			int attVariablez = p.getLevelForXP(0);
			int attVariable1 = attVariablez / 10;
			attVariable = attVariable1 * 2;
			if (attVariable <= 1) {
				attVariable = 2;
			}
			p.skillLvl[0] = p.getLevelForXP(0);
			p.skillLvl[0] += attVariable;
			p.frames.setSkillLvl(p, 0);
			p.requestAnim(829, 0);
			p.potionType = 0;
			p.usingPotion = true;
			p.statDelay = 45;
			p.eatDelay = 1;
			p.frames.playSound(p, 2401, 1, 0);
		break;


			/**
			 * Food
			 */
		case 315:
			p.frames.playSound(p, 2393, 1, 0);
			p.frames.sendMessage(p, "You eat the Shrimps.");
			p.requestAnim(829, 0);
			Engine.playerItems.deleteItem(p, 315, itemSlot, 1);
			p.updateHP(1, true);
			p.eatDelay = 3;
			p.combatDelay = 5;
		break;

		case 359:
			p.frames.playSound(p, 2393, 1, 0);
			p.frames.sendMessage(p, "You eat the Tuna.");
			p.requestAnim(829, 0);
			Engine.playerItems.deleteItem(p, 359, itemSlot, 1);
			p.updateHP(10, true);
			p.eatDelay = 3;
			p.combatDelay = 5;
		break;

		case 373:
			p.frames.playSound(p, 2393, 1, 0);
			p.frames.sendMessage(p, "You eat the Swordfish.");
			p.requestAnim(829, 0);
			Engine.playerItems.deleteItem(p, 373, itemSlot, 1);
			p.updateHP(14, true);
			p.eatDelay = 3;
			p.combatDelay = 5;
		break;

		case 379:
			p.frames.playSound(p, 2393, 1, 0);
			p.frames.sendMessage(p, "You eat the Lobster.");
			p.requestAnim(829, 0);
			Engine.playerItems.deleteItem(p, 379, itemSlot, 1);
			p.updateHP(12, true);
			p.eatDelay = 3;
			p.combatDelay = 5;
		break;

		case 385:
			p.frames.playSound(p, 2393, 1, 0);
			p.frames.sendMessage(p, "You eat the shark.");
			p.requestAnim(829, 0);
			Engine.playerItems.deleteItem(p, 385, itemSlot, 1);
			p.updateHP(20, true);
			p.eatDelay = 3;
			p.combatDelay = 5;
		break;
		
			case 10476:
			p.frames.playSound(p, 2393, 1, 0);
			p.frames.sendMessage(p, "You eat some sweets.");
			p.requestAnim(829, 0);
			Engine.playerItems.deleteItem(p, 10476, itemSlot, 1);
			p.updateHP(7, true);
			p.eatDelay = 3;
			p.combatDelay = 5;
		break;

		case 7946:
			p.frames.playSound(p, 2393, 1, 0);
			p.frames.sendMessage(p, "You eat the Monkfish.");
			p.requestAnim(829, 0);
			Engine.playerItems.deleteItem(p, 7946, itemSlot, 1);
			p.updateHP(22, true);
			p.eatDelay = 3;
			p.combatDelay = 5;
		break;

		case 395:
			p.frames.playSound(p, 2393, 1, 0);
			p.frames.sendMessage(p, "You eat the sea turtle.");
			p.requestAnim(829, 0);
			Engine.playerItems.deleteItem(p, 395, itemSlot, 1);
			p.updateHP(20, true);
			p.eatDelay = 3;
			p.combatDelay = 5;
		break;

		case 391:
			p.frames.playSound(p, 2393, 1, 0);
			p.frames.sendMessage(p, "You eat the manta ray.");
			p.requestAnim(829, 0);
			Engine.playerItems.deleteItem(p, 391, itemSlot, 1);
			p.updateHP(22, true);
			p.eatDelay = 3;
			p.combatDelay = 5;
		break;

            case 3049: // Toadflax
		Engine.playerItems.addItem(p, 2998, 1);
		Engine.playerItems.deleteItem(p, 3049, 3049, 1); 
		p.frames.sendMessage(p, "You clean the herb.");  
		p.addSkillXP(8,15);
                break;
            case 3051: // Snapdragon
		Engine.playerItems.addItem(p, 3000, 1);
		Engine.playerItems.deleteItem(p, 3051, 3051, 1); 
		p.frames.sendMessage(p, "You clean the herb.");  
		p.addSkillXP(11.3,15);
                break;
            case 215: // Cadantine
		Engine.playerItems.addItem(p, 265, 1);
		Engine.playerItems.deleteItem(p, 215, 215, 1); 
		p.frames.sendMessage(p, "You clean the herb.");  
		p.addSkillXP(12.5,15);
                break;
            case 217: // Dwarf Weed
		Engine.playerItems.addItem(p, 267, 1);
		Engine.playerItems.deleteItem(p, 217, 217, 1); 
		p.frames.sendMessage(p, "You clean the herb.");  
		p.addSkillXP(13.8,15);
                break;
            case 219: // Torstol
		Engine.playerItems.addItem(p, 269, 1);
		Engine.playerItems.deleteItem(p, 219, 219, 1); 
		p.frames.sendMessage(p, "You clean the herb.");  
		p.addSkillXP(15,15);
                break;
            case 2485: // Lantadyme
		Engine.playerItems.addItem(p, 2481, 1);
		Engine.playerItems.deleteItem(p, 2485, 2485, 1); 
		p.frames.sendMessage(p, "You clean the herb.");  
		p.addSkillXP(13.1,15);
                break;
            case 199: // Guam
		Engine.playerItems.addItem(p, 249, 1);
		Engine.playerItems.deleteItem(p, 199, 1);
		p.frames.sendMessage(p, "You clean the herb.");  
		p.addSkillXP(2.5,15);
                break;
            case 201: // Marentill
		Engine.playerItems.addItem(p, 251, 1);
		Engine.playerItems.deleteItem(p, 201, 201, 1); 
		p.frames.sendMessage(p, "You clean the herb.");  
		p.addSkillXP(3.8,15);
                break;
            case 203: // Tarromin
		Engine.playerItems.addItem(p, 253, 1);
		Engine.playerItems.deleteItem(p, 203, 203, 1); 
		p.frames.sendMessage(p, "You clean the herb.");  
		p.addSkillXP(5,15);
                break;
            case 205: // Harralander
		Engine.playerItems.addItem(p, 255, 1);
		Engine.playerItems.deleteItem(p, 205, 205, 1); 
		p.frames.sendMessage(p, "You clean the herb.");  
		p.addSkillXP(6.3,15);
                break;
            case 209: // Irit
		Engine.playerItems.addItem(p, 259, 1);
		Engine.playerItems.deleteItem(p, 209, 209, 1); 
		p.frames.sendMessage(p, "You clean the herb.");  
		p.addSkillXP(8.8,15);
                break;
            case 211: // Avantoe
		Engine.playerItems.addItem(p, 261, 1);
		Engine.playerItems.deleteItem(p, 211, 211, 1); 
		p.frames.sendMessage(p, "You clean the herb.");  
		p.addSkillXP(10,15);
                break;
            case 213: // Kwuarm
		Engine.playerItems.addItem(p, 263, 1);
		Engine.playerItems.deleteItem(p, 213, 213, 1); 
		p.frames.sendMessage(p, "You clean the herb.");  
		p.addSkillXP(11.3,15);
                break;
            case 207: // Ranarr 
		Engine.playerItems.addItem(p, 257, 1);
		Engine.playerItems.deleteItem(p, 207, 207, 1); 
		p.frames.sendMessage(p, "You clean the herb.");  
		p.addSkillXP(7.5,15);
                break;


            default:
                Misc.println("[" + p.username + "] Unhandled item selected: " + interfaceId + ":" + itemId + ":" + itemSlot);
                break;
            }
        } else {
            Misc.println("[" + p.username + "] Unhandled item select " + interfaceId + ":" + itemId);
        }
    }
}
